import { createStore } from 'vuex'

export default createStore({
  state: {
    messages:[{
      role: 'assistant',
      content: '你好！我是聊天助手，请问有什么问题？'
    }]
  },
  mutations: {
    setMessages(state, messages) {
      state.messages = messages
      sessionStorage.setItem('messages', JSON.stringify(messages))
    },
  },
  getters: {
    getMessages(state) {
      return state.messages || JSON.parse(sessionStorage.getItem('messages'))
    },
  },
})